<table class="table table-bordered">
	<tbody>
		<tr><td style="background:#F5F5F5" width=80>充值密码:</td><td class="chargePwd"><input type="password" name="chargePwd" disabled placeholder="" value="123123"></td><td width=120><input type="button" class="btn" value="修改" target="chargePwd" name="edit" id="chargePwd"></td></tr>
		<tr><td style="background:#F5F5F5">号码单价:</td><td><input type="number" name="mobile-unit-price" value="" disabled/></td><td><input type="button" class="btn" value="修改" id="mobile-unit-price" target="mobile-unit-price" name="edit"></td></tr>
		<tr><td style="background:#F5F5F5">通话单价:</td><td><input type="number" name="call-unit-price" disabled/></td><td><input type="button" class="btn" value="修改" target="call-unit-price" name="edit" id="call-unit-price"></td></tr>
	</tbody>
</table>
<script>
	$(function(){
		var defaultValue = "";
		$("input[name='edit']").bind("click",function(){
			if($(this).val() == "保存"){
					switch($(this).attr("target")){
						case 'chargePwd' :
										var $charge_pwd =  getInputValueByName('chargePwd');
										$.getJSON('__APP__/Voice/setChargePWD',{chargePWD:$charge_pwd},function(json){
											if(json.status == 1){
												alert(json.info);
												$("input[name='password'],input[name='repassword']").remove();
												$("input[name='"+$(this).attr("target")+"']").attr("disabled",true).val(defaultValue);
												$(this).remove();
												
											}else{
												alert(json.info);
											}
										});
										 break;
						case 'mobile-unit-price' :
										var $charge_pwd =  getInputValueByName('mobile-unit-price');
										$.getJSON('__APP__/Voice/setVoiceConfig',{phone_unit_price:$charge_pwd},function(json){
											if(json.status == 1){
												alert(json.info);
												$("input[name='"+$(this).attr("target")+"']").attr("disabled",true);
												$(this).remove();
												
											}else{
												alert(json.info);
											}
										});

										 break;
						case 'call-unit-price' :
										var $charge_pwd =  getInputValueByName('call-unit-price');
										$.getJSON('__APP__/Voice/setVoiceConfig',{call_unit_price:$charge_pwd},function(json){
											if(json.status == 1){
												alert(json.info);
												$("input[name='"+$(this).attr("target")+"']").attr("disabled",true);
												$(this).remove();
												
											}else{
												alert(json.info);
											}
										});
										 break;
					}
					
					return;

			}
			if($(this).attr("target") == "chargePwd"){

				

				$(this).val("保存").parent().append("<input type='button' class='btn' value='取消' name='cancel' style='margin-left:5px' target='chargePwd'>");
				defaultValue = $("input[name='chargePwd']").val();
				$("input[name='chargePwd']").attr({placeholder:"请输入旧密码",disabled:false}).val("");
				$(".chargePwd").append("<input type='password' name='password' placeholder='请输入新密码' style='margin:0 5px 0 5px;'/><input type='password' name='repassword' placeholder='请再次输入新密码'/>");
				return;
			}
			$("input[name='"+$(this).attr("target")+"']").attr("disabled",false);
			$(this).val("保存").parent().append("<input type='button' class='btn' value='取消' name='cancel' style='margin-left:5px' target='"+$(this).attr("target")+"'>");
		});
		$("input[name='cancel']").live("click",function(){
			$("#"+$(this).attr("target")).val("修改");
			if($(this).attr("target") == "chargePwd"){
				$("input[name='password'],input[name='repassword']").remove();
				$("input[name='"+$(this).attr("target")+"']").attr("disabled",true).val(defaultValue);
				$(this).remove();
				return;
			}
			$("input[name='"+$(this).attr("target")+"']").attr("disabled",true);
			$(this).remove();
		});
	});
	function edit(attr){
		alert(attr);
	}
</script>